using System;
using System.Collections.Generic;
using System.ServiceModel;
using SharedObjects;

namespace TheGame.Webservices
{
	// ReSharper disable InconsistentNaming
	[ServiceContract(
		Name = "TheGameService", 
		Namespace = "TheGame.Webservices",
		SessionMode = SessionMode.Required,
		CallbackContract = typeof(ITheGameServiceCallback)
		)]
	public interface ITheGameService
	{
		#region public methods

		[OperationContract] void ServiceConnect();
		#region Login/Logout/Register
		//[OperationContract] bool RegisterAccount(string login, string password, string agentName, Guid corporationId);
		[OperationContract] bool VerifySession(Guid sessionId);
		[OperationContract] ClientConfiguration Login(string login, string password);
		[OperationContract] bool Logout(Guid sessionId, string login, string password);
		[OperationContract] List<SmallComputerSystem> GetMyKnownComputerSystems(Guid sessionId);
		#endregion

		#region File system
		[OperationContract] List<SystemFile> GetFilesInDirectory(Guid sessionId, ulong directoryId);
		[OperationContract] List<SystemFile> GetSystemRoot(Guid agentId, ulong systemId);
		#endregion

		#region Gateway
		[OperationContract] int GetMyTotalMemory(Guid sessionId);
		[OperationContract] double GetMyTotalCpuSpeed(Guid sessionId);
		[OperationContract] double GetMyTotalBandwidth(Guid sessionId);
		[OperationContract] double GetProgramSpeed(Guid sessionId, ulong programId);
		[OperationContract] bool CreateAndAssignGateway(Guid agentId, Gateway newGateway);
		#endregion

		#region Programs
		[OperationContract]
		bool ExecuteProgram(Guid sessionID, ulong programId, object[] parameters);
		[OperationContract] List<Program> GetMyPrograms(Guid sessionId);
		#endregion

		#region ComputerSystem connections
		[OperationContract] Guid? Connect_ConnectToSystem(Guid sessionId, List<ulong> connectionPathIds);
		[OperationContract] List<ComputerSystemFeature> Connect_GetConnectedHostFeatures(Guid sessionId, Guid connectionId);
		[OperationContract] bool Connect_TryAccess(Guid sessionId, Guid connectionId, ulong securitySystemId, object[] methodParameters);
		[OperationContract] bool Connect_LoginToSystemAllowed(Guid sessionId, Guid connectionId);
		[OperationContract] bool Connect_LoginToSystem(Guid sessionId, Guid connectionId);
		[OperationContract] bool Connect_DisconnectFromSystem(Guid sessionId, Guid connectionId);
		[OperationContract] List<SavedConnection> Connect_GetConnections(Guid sessionId);
		[OperationContract] bool Connect_SaveConnection(Guid sessionId, SavedConnection conn);
		#endregion

		#region ComputerSystem activities
		[OperationContract] List<ReadableComputerSystemLog> GetSystemLogs(Guid sessionId, ulong systemId);
		[OperationContract] bool CreateSystemAccount(Guid sessionId, ulong systemId, ComputerSystemAccount account);
		#endregion

		#region Chat
		[OperationContract] void SendChatMessage(Guid sessionId, ChatMessage message);
		[OperationContract] void SendGlobalChatMessage(Guid sessionId, ChatMessage message);
		#endregion

		#region Email
		[OperationContract] bool CreateEmailAccount(Guid sessionId, ulong systemId, string accountName);
		[OperationContract] bool SendEmail(Guid sessionId, ulong systemId, ulong accountId, EmailHeader header, EmailBody body);
		[OperationContract] List<ShortEmailAccountInfo> GetEmailAccountsForSystem(Guid sessionId, ulong systemId);
		[OperationContract] List<EmailHeader> GetEmailsForFolder(Guid sessionId, ulong systemId, ulong accountId, EmailFolder folder);
		[OperationContract] bool MoveEmail(Guid sessionId, ulong systemId, ulong accountId, ulong EmailHeaderId, EmailFolder folder);
		[OperationContract] bool DeleteEmail(Guid sessionId, ulong systemId, ulong accountId, ulong EmailHeaderId);
		[OperationContract] bool MarkEmailAsSpam(Guid sessionId, ulong systemId, ulong accountId, ulong EmailHeaderId);
		[OperationContract] EmailBody GetEmailBody(Guid sessionId, ulong systemId, ulong accountId, ulong headerId);
		[OperationContract] string GetHostnameAddress(Guid sessionId, ulong systemId);
		#endregion

		#region Banking
		[OperationContract] long CreateBankAccount(Guid sessionId, ulong systemId);
		[OperationContract] List<BankAccount> GetBankAccount(Guid sessionId, ulong systemId);
		[OperationContract] List<ReadonlyBankTransaction> GetBankAccountMutations(Guid sessionId, ulong systemId, long accountNumber);
		[OperationContract] bool CreateTransaction(Guid sessionId, ulong systemId, long accountNumber, long receivingAccountNumber, string bankName, long amount, string purpose);
		#endregion

		#region Market
		[OperationContract] long GetAvailableFunds(Guid sessionId, ulong systemId);
		[OperationContract] List<MarketItem> GetAvailableSoftware(Guid sessionId, ulong systemId);
		[OperationContract] List<MarketItem> GetAvailableHardware(Guid sessionId, ulong systemId);
		[OperationContract] bool PurchaseProgram(Guid sessionId, ulong systemId, ulong itemId);
		[OperationContract] bool PurchaseHardware(Guid sessionId, ulong systemId, ulong itemId);
		#endregion

		#region Hardware
		[OperationContract] ShallowGateway GetGatewayDetails(Guid sessionId);
		[OperationContract] GatewayBlueprint GetGatewayBlueprintDetails(Guid sessionId, ulong blueprintId);
		[OperationContract] List<EntityBase> GetCurrentHardware(Guid sessionId);
		[OperationContract] List<EntityBase> GetStoredHardware(Guid sessionId);
		[OperationContract] bool ScheduleGatewayReconfiguration(Guid sessionId, ShallowGateway sgw, bool immediate);
		#endregion

		#region Board
		[OperationContract] List<UsenetMessage> Usenet_GetThreads(Guid sessionId, ulong systemId, DateTime fromDate, DateTime toDate);
		[OperationContract] List<UsenetMessage> Usenet_GetThreadMessages(Guid sessionId, ulong systemId, ulong rootMessageId);
		[OperationContract] bool Usenet_PostMessage(Guid sessionId, ulong systemId, UsenetMessage msg);
		#endregion
		#endregion

		#region StoryDesign functions
		[OperationContract] List<StoryArc> StoryDesign_GetMyArcs(Guid sessionId);
		[OperationContract] bool StoryDesign_SaveArc(Guid sessionId, StoryArc arc);
		#endregion
	}

	public interface ITheGameServiceCallback
	{
		[OperationContract(IsOneWay = true)] void Heartbeat(DateTime WorldTime);
		[OperationContract(IsOneWay = true)] void ServerError(ServerErrorSeverity Severity, string Message);
		[OperationContract(IsOneWay = true)] void Trace(Guid ConnectionId, int RemainingMilliSeconds, List<object> OptionalInformation);
		[OperationContract(IsOneWay = true)] void TraceEnded(Guid ConnectionId, bool HasTraceTimeElapsed);
		[OperationContract(IsOneWay = true)] void Email(string senderEmailAddress, string serverName);
		[OperationContract(IsOneWay = true)] void BankTransaction(long Amount, string SendingAccount, string ReceivingAccount, DateTime transactionDate);
		[OperationContract(IsOneWay = true)] void GlobalChatMessage(ChatMessage message);
		[OperationContract(IsOneWay = true)] void LocalChatMessage(ChatMessage message);
		[OperationContract(IsOneWay = true)] void ServerDisconnect();
		[OperationContract(IsOneWay = true)] void RebootForHardwareChange();
	}
	// ReSharper restore InconsistentNaming
}